<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>

	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<%@ include file="/common/ssb/include/common-base.jsp"%>
	<title>账号密码修改</title>
</head>
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

	<!-- top start -->
	<%@include file="/common/ssb/top.jsp" %>
	<!-- top end -->

	<!-- left start -->
	<%@include file="/common/ssb/left.jsp" %>
	<!-- left end-->

	<div class="content-wrapper">
		<section class="content">
			<div class="row">
				<div class="col-lg-12">
					<div class="panel">
						<div class="panel-heading">
							<h3 style="font-size:18px;">
								<i class="fa fa-key"></i> 密码修改
							</h3>
						</div>
						<div class="panel-body">
							<div class="col-xs-6">
								<input type="hidden" id="uctUser_old_userPass" value="${loginUser.userPass}"/>
								<form class="form-horizontal editpassFormBody" role="form" id="editpassForm1" action="javascript:void(0)">
									<input type="hidden" class="formToken" id="editpassForm1_formToken" name="formToken" />
									<!-- temp="editpassForm1_hidden" start -->
									<div id="editpassForm1_hidden">
										<input type="hidden" name="pageName" value="user-list"/>
										<input type="hidden" name="formName" value="editForm"/>
										<input type="hidden" name="uctUser.w_userId" value="${loginUser.userId}"/>
										<input type="hidden" name="uctUser.userPass" class="clean"/>
									</div>
									<!-- temp="editpassForm1_hidden" end -->

									<!-- temp="editpassForm1_content" start -->
									<div id="editpassForm1_content">

										<table class="table table-bordered bordercolor">
											<tbody>
											<tr>
												<td class="active" align="right"><label class="form-control-static">登录账号：</label></td>
												<td>
													<div class="form-control-static">${loginUser.userEname}</div>
												</td>
											</tr>
											<tr>
												<td class="active" align="right"><label class="form-control-static">用户名称：</label></td>
												<td>
													<div class="form-control-static">${loginUser.userCname}</div>
												</td>
											</tr>
											<tr>
												<td class="active" align="right"><label
														class="form-control-static">新的密码：</label></td>
												<td>
													<div class="form-group"><input name="userPass1"
																				   class="form-control clean"
																				   maxlength="30"
																				   placeholder="请输入新的密码"
																				   data-bv-notempty="true"
																				   data-bv-notempty-message="新的密码不能为空"
																				   type="password"
																				   data-bv-regexp="true" data-bv-regexp-regexp="^[^ ]{6,}$"
																				   data-bv-regexp-message="至少6位的非空格字符"></div>
												</td>
											</tr>
											<tr>
												<td class="active" align="right"><label
														class="form-control-static">确认密码：</label></td>
												<td>
													<div class="form-group"><input name="userPass2"
																				   class="form-control clean"
																				   maxlength="30"
																				   placeholder="请再次输入新的密码"
																				   data-bv-notempty="true"
																				   data-bv-notempty-message="请再次输入确认密码"
																				   type="password"></div>
												</td>
											</tr>

											</tbody>
										</table>

									</div>
									<!-- temp="editpassForm1_content" end -->

									<div class="form-group">
										<div class="col-sm-12">
											<div class="box-footer text-center" id="div_footer_msg">
												<button class="btn btn-success" type="button" onclick="mytools.cleanData('.editpassFormBody');"> 重置 </button>&nbsp;&nbsp;&nbsp;
												<button class="btn btn-danger" type="button" onclick="submitForm1('editpassForm1','');" data-temp-event="editpassForm1_hidden"> 提交 </button>
											</div>
										</div>
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>

<script>
	var clickMenu = "user-pass";
	var formId = "#editpassForm1";
	$(function () {
		mytools.cleanData(".editpassFormBody");
		setValidate(formId);//定义add表单验证属性
		mytools.cleanValidate(formId);//清空上次校验规则提示
		if('${loginUser.userEname}'=='admin'){
			$(formId).find("input[name='userPass1']").prop("readonly", true);
			$(formId).find("input[name='userPass2']").prop("readonly", true);
			$("#div_footer_msg").html("<div class='red f20'>特殊账号，不允许进行密码修改操作！</div>");
		}
	});

	//提交tab1表单数据
	function submitForm1(formId,tabId){
		//校验规则-表单提交时触发
		var validate = $('#'+formId).data('bootstrapValidator').validate();
		if(!validate.isValid()){ //如果校验不通过就返回
			return;
		}
		var uctUser_old_userPass = $("#uctUser_old_userPass").val();
		var userPass1 = $('#'+formId).find("input[name='userPass1']").val();
		if(userPass1.md5()==uctUser_old_userPass){
			layer.alert("新密码不能和旧密码相同！", {closeBtn: 0});
			mytools.cleanData(".editpassFormBody");
			return;
		}
		var userPass2 = $('#'+formId).find("input[name='userPass2']").val();
		if(userPass1!=userPass2) {
			layer.alert("两次输入密码不一致！", {closeBtn: 0});
			$('#' + formId).find("input[name='userPass2']").val("");
			return;
		}
		$('#'+formId).find("input[name='uctUser.userPass']").val(userPass1.md5());

		var index_submit = layer.confirm('您确定要提交密码修改操作吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
		, function(){
			var result = submitForm(formId,tabId);
			if(result){
				layer.alert("修改成功，请退出重新登录！", {closeBtn: 0 });
				window.location.href='${ctx}/logout';
			}
		});

	}
	//提交表单数据
	function submitForm(formId,tabId){
		var result;
		var index_load = layer.load(1, {shade: false});
		$.ajax({
			type:'post',
			url:common_submit_url,
			data:$("#"+formId).serialize(),
			async:false,
			dataType:'json',
			success: function(myData){
				console.log(myData);
				if(myData.flag=="T"){
					result = myData;
				}else{
					setToken();
					layer.alert(myData.msg);
				}
				layer.close(index_load);
			},
			error: function (e) {
				layer.close(index_load);
			}
		});
		return result;
	}
	/**** Part 四、以下是自定义新增方法  ****/
//1.定义校验规则-定义
	function setValidate(id){
		$(id).each(function(){
			$(this).bootstrapValidator({
				feedbackIcons: {
					valid: 'glyphicon glyphicon-ok',
					invalid: 'glyphicon glyphicon-remove',
					validating: 'glyphicon glyphicon-refresh'
				},/** 以下需要结合实际业务清空补充个表单元素的验证规则 **/
				fields:{
					/** 可自定义新增验证规则
					 "uctUser.userEname":{
						validators: {
						 regexp: {
							 regexp: /^[0-9]+$/,
							  message: '只能是数字'
						  }
						}
}
					 **/
				}
			});
		});
	}
</script>

		</section>
	</div>

	<!-- foot start -->
	<%@include file="/common/ssb/foot.jsp" %>
	<!-- foot start -->

</div>

</body>
</html>




